/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wf.model;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import wf.units.DatabaseUnit;

/**
 *
 * @author bennyl
 */
@DatabaseTable(tableName="counters")
public class Counter{
    
    @DatabaseField(generatedId=true)
    int id;
    
    @DatabaseField(canBeNull=false)
    String name;
    
    @DatabaseField(canBeNull=false)
    String plcIP;
    
    @DatabaseField(canBeNull=false)
    double pulseResolution;
    
    @DatabaseField(canBeNull=false)
    int port;

    public Counter() {
    }

    public Counter(int id, String name, String plcIP, double pulseResolution, int port) {
        this.id = id;
        this.name = name;
        this.plcIP = plcIP;
        this.pulseResolution = pulseResolution;
        this.port = port;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPlcIP() {
        return plcIP;
    }

    public void setPlcIP(String plcIP) {
        this.plcIP = plcIP;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public double getPulseResolution() {
        return pulseResolution;
    }

    public void setPulseResolution(double pulseResolution) {
        this.pulseResolution = pulseResolution;
    }

    @Override
    public String toString() {
       return getName() + "@" + DatabaseUnit.UNIT.selectPLCByIP(getPlcIP());
    }

}
